import Vue from 'vue'
import App from './App.vue'
import store from './store/index'
import router from './router'
import {
	axios,
	uploadFill
} from './server'
import VueBus from 'vue-bus'
import $tool from './tool/index.js'

import VueClipboard from 'vue-clipboard2' // 复制剪切板
Vue.use(VueClipboard) // 通过$copyText即可复制 返回promise

import GSignInButton from 'vue-google-signin-button'
Vue.use(GSignInButton)
import FBSignInButton from 'vue-facebook-signin-button'
Vue.use(FBSignInButton)



import '@/assets/js/flexible.js';

// 引入UI库
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './assets/css/init_element.css'
import Vant from 'vant';
import 'vant/lib/index.css';
import VueAwesomeSwiper from 'vue-awesome-swiper'
import '@/assets/js/flexible.js'

import "swiper/css/swiper.css";
import "swiper/js/swiper";
import locale from 'element-ui/lib/locale/lang/ja'

Vue.use(ElementUI, {
	locale
})

import VueI18n from 'vue-i18n'
Vue.use(VueI18n) // 通过插件的形式挂载
const i18n = new VueI18n({
	locale: 'jp-JP', // 语言标识
	//this.$i18n.locale // 通过切换locale的值来实现语言切换
	messages: {
		'zh-CN': require('./lang/zh'), // 中文语言包
		'en-US': require('./lang/en'), // 英文语言包
		'jp-JP': require('./lang/jp'), // 日文语言包
	}
})
// vant 语言包
import {
	Locale,
	Toast,
	ImagePreview
} from 'vant';
// 引入英文语言包
import jaJP from 'vant/es/locale/lang/ja-JP';
Locale.use('en-US', jaJP);
Vue.prototype.ImagePreview = ImagePreview
Vue.use(ImagePreview);

Vue.use(Vant);
Vue.use(ElementUI)
Vue.use(VueBus);
Vue.config.productionTip = false
Vue.prototype.$axios = axios
Vue.prototype.$uploadFill = uploadFill
Vue.prototype.$Toastclear = Toast.clear // this.$Toastclear()
Vue.prototype.$tool = $tool
Vue.prototype.showToast = (enMsg, jpMSg, icon = 'none', duration = '2000') => {
	// 通过this.showToast()使用 
	if (i18n.locale == 'en-US') {
		Toast({
			message: enMsg,
			icon,
			duration
		})
	} else {
		Toast({
			message: jpMSg || enMsg,
			icon,
			duration
		})
	}
}
Vue.prototype.$loading = (duration = 1500) => {
		let msg = i18n.locale == 'en-US' ? 'loading...' : 'ロード中...'
		// 通过this.$loading()使用	
		Toast.loading({
			message: msg,
			forbidClick: true,
			duration
		})
	},

	new Vue({
		i18n,
		router,
		store,
		render: h => h(App),
	}).$mount('#app')
